// 资源详情js
var $scope = null;
$(function() {
	var appElement = document.querySelector('[ng-controller=main]');
	$scope = angular.element(appElement).scope();
	var imageTypeId = locationHref("imageTypeId");
	var imageId = locationHref("imageId");
	var imageItemId = locationHref("imageItemId");
	var pageNumber = locationHref("pageNumber");
	$scope.imageTypeId = imageTypeId;
	$scope.imageId = imageId;
	$scope.imageItemId = imageItemId;
	$scope.pageNumber = pageNumber;
	console.log($scope.pageNumber)
	$scope.methods.imageList();

});

var mainApp = angular.module("mainApp", []);
mainApp.controller('main', function($scope) {
	$scope.currentImageIndex = 0;
	$scope.dynamicData = [];
	$scope.search = {};
	$scope.methods = {
		//动态列表
		imageList: function() {
			console.log("made")
			var params = '';
			params += '&pageNum=1'
			params += '&pageSize=10000'
			if($scope.imageTypeId){
				params += '&imageTypeId='+$scope.imageTypeId
			}
			if($scope.imageId){
				params += '&imageId='+$scope.imageId
			}
			
			$.ajax({
				url: $.shysUrlPrefix + '/website/imageList?' + params,
				type: 'get',
				dataType: 'JSON',
				async: true, //同步方式发起请求
				success: function(data) {
					if (data.rows != null && data.rows.length > 0 ) {
						$.each(data.rows,function(i,item){
												 if(data.rows[i].imageUrl){
													data.rows[i].imageUrlNew=data.rows[i].imageUrl+'?x-oss-process=image/auto-orient,1/watermark,color_FFFFFF,type_ZHJvaWRzYW5zZmFsbGJhY2s,text_QOahpeaigeWcqOe6vw';
													data.rows[i].imageUrl=data.rows[i].imageUrl+'?x-oss-process=image/auto-orient,1/watermark,color_FFFFFF,size_60,type_ZHJvaWRzYW5zZmFsbGJhY2s,text_QOahpeaigeWcqOe6vw,image/resize,m_pad,h_645,w_1000,color_000000' 
												 }					
						}),
						$scope.dynamicData = data.rows; //
						$scope.imageTypeName = data.rows[0].imageTypeName; //
						$scope.$apply();
						
					} else {

					}

				},

			})
		},
		
	
	};
});
